package com.atshiyou.dao;

import com.atshiyou.Util.SqlUtil;
import com.atshiyou.bean.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@CacheNamespace
public interface StudentDao2 {
    //增删改查
    @InsertProvider(type = SqlUtil.class,method = "insertMethod")
    @Options(useGeneratedKeys = true,keyProperty = "stuId") //获取新增数据的id
    public int insertStu(Student student);

    //删除
    @DeleteProvider(type = SqlUtil.class,method = "deleteMethod")
    public int delete(int sid);

    //修改
    @UpdateProvider(type = SqlUtil.class,method = "updateMethod")
    public int updateStu(Student student);

    //查询
    @Options(useCache = true,flushCache = Options.FlushCachePolicy.FALSE,timeout = 9999999)
    @SelectProvider(type = SqlUtil.class,method = "findAllMethod")
    public List<Student> findAll();

    @SelectProvider(type = SqlUtil.class,method = "totalCountMethod")
    public int totalCount();
    //计算出ID的最大值，最小值，平均值

    @SelectProvider(type = SqlUtil.class,method = "total2Method")
    public Map total2();

    //两表联查，查询学生信息以及班级的情况
    @Select("select * from student s,grade g where s.gid = g.gradeid")
    @ResultMap("com.atshiyou.dao.StudentDao2.rs1")
    public List<Student> getAllStu();




}
